<?php

class PhotoService extends Service_Base implements ISingleton 
{
	/**
	 *
	 * @var PhotoService
	 */
	private static $_instance;
	
	/**
	 *
	 * @return PhotoService
	 */
	public static function getInstance()
	{
		if (!self::$_instance) {
			self::$_instance = new self();
		}
		return self::$_instance;
	}
	
	public function getLatestGalleries()
	{
		$peer = PhotoGalleryPeer::getInstance();
		$select = $peer->select();
		$select->limit(25);
		$select->order('created desc');
		$rowset = $peer->fetchAll($select);
		return $rowset;
	}
	
	public function getPopularPhotos()
	{
		$peer = FilePeer::getInstance();
		$select = $peer->select()->order('rating desc')->limit(5);
		return $peer->fetchAll($select);
	}
	
	public function getLastPhotos()
	{
		$peer = FilePeer::getInstance();
		$select = $peer->select()->order('created desc')->limit(9);
		return $peer->fetchAll($select);
	}
	
	public function getMostCommentedPhotos()
	{
		$peer = FilePeer::getInstance();
		$select = $peer->select()->order('total_comments desc')->limit(5);
		return $peer->fetchAll($select);
	}
}			